package com.palandrodev.calsmart.base;

/**
 * 
 * @author Palaniappan
 * @version 1.1
 * @since October 05 2013
 */
public class SimpleInterest {

	private float principle;
	private float interest;
	private float duration;

	public SimpleInterest() {
		this.principle = 0.0f;
		this.interest = 0.0f;
		this.duration = 0.0f;
	}

	public SimpleInterest(float param_principle, float param_duration,
			float param_interest) {
		this.principle = param_principle;
		this.duration = param_duration;
		this.interest = param_interest;

	}

	public float getPrinciple() {
		return principle;
	}

	public void setPrinciple(float param_principle) {
		this.principle = param_principle;
	}

	public float getInterest() {
		return interest;
	}

	public void setInterest(float param_interest) {
		this.interest = param_interest;
	}

	public float getDuration() {
		return duration;
	}

	public void setDuration(float param_duration) {
		this.duration = param_duration;
	}

	public float calculate() {
		return this.principle * this.duration * (this.interest / 100);
	}

	public boolean isEmpty() {
		if ((this.principle == 0.0f) && (this.duration == 0.0f)
				&& (this.interest == 0.0f)) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public String toString() {
		return "SimpleInterest [principle=" + principle + ", interest="
				+ interest + ", duration=" + duration + "]";
	}

	@Override
	public int hashCode() {
		if (this.isEmpty()) {
			return 0;
		} else {
			final int prime = 31;
			int result = 1;
			result = prime * result + Float.floatToIntBits(duration);
			result = prime * result + Float.floatToIntBits(interest);
			result = prime * result + Float.floatToIntBits(principle);
			return result;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SimpleInterest other = (SimpleInterest) obj;
		if (Float.floatToIntBits(duration) != Float
				.floatToIntBits(other.duration))
			return false;
		if (Float.floatToIntBits(interest) != Float
				.floatToIntBits(other.interest))
			return false;
		if (Float.floatToIntBits(principle) != Float
				.floatToIntBits(other.principle))
			return false;
		return true;
	}

}
